home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Aminet 28
/
Aminet 28 (1998)(GTI - Schatztruhe)[!][Dec 1998].iso
/
Aminet
/
dev
/
lang
/
fpc09905c.lha
/
fpc
/
utils
/
dumpppu.pp
< prev
next >
Wrap
Text File
|
1998-09-21
|
28KB
|
802 lines
{****************************************************************************
$Id: dumpppu.pp,v 1.7 1998/08/12 12:17:07 carl Exp $
Dumps the contents of a FPC unit file (PPU File)
Copyright (c) 1995,97 by Florian Klaempfl and Michael Van Canneyt
Members of the FPC Development Team
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
****************************************************************************}
{
possible compiler switches (* marks a currently required switch):
-----------------------------------------------------------------
BIG_ENDIAN Target machine on which this machine will run is
a BIG endian machine (such as the m68k)
}
{$ifdef TP}
{$N+,E+,G+}
{$endif}
program dumpppu;
var
f : file;
version : longint;
Filename : string;
nrfile : longint;
flags : byte;
const
ibloadunit = 1;
iborddef = 2;
ibpointerdef = 3;
ibtypesym = 4;
ibarraydef = 5;
ibprocdef = 6;
ibprocsym = 7;
iblinkofile = 8;
ibstringdef = 9;
ibvarsym = 10;
ibconstsym = 11;
ibinitunit = 12;
ibaufzaehlsym = 13;
ibtypedconstsym = 14;
ibrecorddef = 15;
ibfiledef = 16;
ibformaldef = 17;
ibobjectdef = 18;
ibenumdef = 19;
ibsetdef = 20;
ibprocvardef = 21;
ibsourcefile = 22;
ibdbxcount = 23;
ibfloatdef = 24;
ibref = 25;
ibextsymref = 26;
ibextdefref = 27;
ibabsolutesym = 28;
ibclassrefdef = 29;
ibpropertysym = 30;
iblibraries = 31;
iblongstringdef = 32;
ibansistringdef = 33;
ibunitname = 34;
ibwidestringdef = 35;
ibstaticlibs = 36;
ibend = 255;
{ unit flags }
uf_init = 1;
uf_uses_dbx = 2;
uf_uses_browser = 4;
uf_in_library = 8;
uf_shared_library = 16;
uf_big_endian = 32;
Type
absolutetyp = (tovar,toasm,toaddr);
tbasetype = (uauto,uvoid,uchar,
u8bit,u16bit,u32bit,
s8bit,s16bit,s32bit,
bool8bit,bool16bit,bool32bit);
{ don't change the order of these - used to determine processor }
{ taken from FPC v0.99.5 systems.pas }
ttarget = (target_GO32V1,target_OS2,target_LINUX,
target_WIN32,target_GO32V2,
target_Amiga,target_Atari,target_Mac68k);
var abstyp : absolutetyp;
utarget : ttarget;
function upper(const s : string) : string;
var
i : longint;
begin
for i:=1 to length(s) do
if s[i] in ['a'..'z'] then
upper[i]:=char(byte(s[i])-32)
else
upper[i]:=s[i];
upper[0]:=s[0];
end;
function readlong : longint;
var
l : longint;
w1, w2: word;
begin
blockread(f,l,4);
{$ifdef BIG_ENDIAN}
w1:=l and $ffff;
w2:=l shr 16;
l:=swap(w2)+(longint(swap(w1)) shl 16);
{$endif}
readlong:=l;
end;
function readword : word;
var
w : word;
begin
blockread(f,w,2);
{$IFDEF BIG_ENDIAN}
w:=swap(w);
{$ENDIF}
readword:=w;
end;
function readdouble : double;
var
d : double;
begin
blockread(f,d,8);
readdouble:=d;
end;
function readbyte : byte;
var
b : byte;
begin
blockread(f,b,1);
readbyte:=b;
end;
function readstring : string;
var
s : string;
begin
s[0]:=chr(readbyte);
blockread(f,s[1],ord(s[0]));
readstring:=s;
end;
var
space : string;
read_member : boolean;
procedure readandwriteref;
var
w : word;
begin
w:=readword;
if w=$ffff then
begin
w:=readword;
if w=$ffff then
writeln('nil')
else writeln('Local Definition Nr. ',w)
end
else writeln('Unit ',w,' Nr. ',readword)
end;
{ reads the flags of a definition }
procedure readflags;
begin
if version<13 then
readword;
end;
var
b : byte;
unitnumber : word;
type
tsettyp = (normset);
procedure readin;
var
oldread_member : boolean;
counter : word;
sourcename : string;
procedure read_abstract_proc_def;
var
params : word;
options : longint;
begin
write(space,' Return type : ');
readandwriteref;
if Version<13 then
options:=readword
else
options:=readlong;
if options<>0 then
begin
write(space,' Options : ');
if (options and 1)<>0 then
write('Exception handler ');
if (options and 2)<>0 then
write('Virtual Method ');
if (options and 4)<>0 then
write('Stack is not cleared, ');
if (options and 8)<>0 then
write('Constructor ');
if (options and $10)<>0 then
write('Destructor ');
if (options and $20)<>0 then
write('Internal Procedure ');
if (options and $40)<>0 then
write('Exported Procedure ');
if (options and $80)<>0 then
write('I/O-Checking');
if (options and $100)<>0 then
write('Abstract method');
if (options and $200)<>0 then
write('Interrupt Handler');
if (options and $400)<>0 then
write('Inline Procedure');
if (options and $800)<>0 then
write('Assembler Procedure');
if (options and $1000)<>0 then
write('Overloaded Operator');
if (options and $2000)<>0 then
write('External Procedure');
if (options and $4000)<>0 then
write('Expects parameters from left to right');
if (options and $8000)<>0 then
write('Main Program');
if (options and $10000)<>0 then
write('Static Method');
if (options and $20000)<>0 then
write('Method with Override Direktive');
if (options and $40000)<>0 then
write('Class Method');
if (options and $80000)<>0 then
write('Unit Initialisation');
if (options and $100000)<>0 then
write('Method Pointer (must be a procedure variable)');
writeln
end;
params:=readword;
writeln(space,' Nr of parameters: ',params);
if params>0 then
writeln(space,' Parameter defs : ');
while params>0 do
begin
write(space,' Type: ',readbyte,' ');
readandwriteref;
dec(params);
end;
end;
var
params : word;
IgnoreEnd : Longint;
begin
counter:=0;
IgnoreEnd:=0;
repeat
b:=readbyte;
if not (b in [ibend,ibloadunit,ibinitunit,iblinkofile,ibsourcefile,
iblibraries,ibunitname,ibstaticlibs]) then
begin
write(space,'Definition Nr. ',counter,' : ');
inc(counter);
end;
case